package ui.panel.trains {
	
	import flash.display.Sprite;
	
	import ui.component.Label;
	import ui.component.TextButton;
	
	import util.UIUtil;
	
	public class TrainDetail extends Sprite {
		
		private var basicTrain:TrainInfo;
		private var expertTrain:TrainInfo;
		private var strongTrain:TrainInfo;
		private var speedTrain:TrainInfo;
		
		private var trainLabel:Label;
		private var timeLabel:Label;
		private var costLabel:Label;
		private var expLabel:Label;
		private var cdLabel:Label;
		private var speedButton:TextButton;

		public function TrainDetail() {
			super();
			
			basicTrain = new TrainInfo();
			basicTrain.x = 100;
			basicTrain.y = 100;
			addChild(basicTrain);
			
			expertTrain = new TrainInfo();
			expertTrain.x = 200;
			expertTrain.y = 100;
			addChild(expertTrain);
			
			strongTrain = new TrainInfo();
			strongTrain.x = 300;
			strongTrain.y = 100;
			addChild(strongTrain);
			
			trainLabel = new Label(12, 0xFFFFFF);
			trainLabel.x = 40;
			trainLabel.y = 200;
			addChild(trainLabel);
			
			speedTrain = new TrainInfo();
			speedTrain.x = 100;
			speedTrain.y = 250;
			addChild(speedTrain);
			
			timeLabel = new Label(12, 0xFFFFFF);
			timeLabel.x = 80;
			timeLabel.y = 250;
			addChild(timeLabel);
			
			costLabel = new Label(12, 0xFFFFFF);
			costLabel.x = 80;
			costLabel.y = 270;
			addChild(timeLabel);
			
			expLabel = new Label(12, 0xFFFFFF);
			expLabel.x = 80;
			expLabel.y = 290;
			addChild(timeLabel);
			
			cdLabel = new Label(12, 0xFFFFFF);
			cdLabel.x = 80;
			cdLabel.y = 340;
			addChild(cdLabel);
			
			speedButton = UIUtil.getTextButton("加速", ["button_yellow_off", "button_yellow_on", "button_yellow_off"], speedHandler);
			speedButton.x = 180;
			speedButton.y = 330;
			addChild(speedButton);
		}
		
		private function speedHandler(buton:TextButton):void {
			
		}
		
		public function updateTrainText(text:String):void {
			trainLabel.text = text;
		}
		
		public function updateSpeedInfo(time:uint, cost:uint, exp:uint):void {
			timeLabel.text = "训练时间：" + time;
			costLabel.text = "消耗：" + cost;
			expLabel.text = "获得经验：" + exp;
		}
		
		public function updateCD(cd:uint):void {
			cdLabel.text = "冷却时间：" + cd;
		}
		
		public function clear():void {
			
		}
	}
}

import flash.display.Bitmap;
import flash.display.Sprite;

import globals.Global;

import ui.component.Label;
import ui.component.TextButton;

import util.UIUtil;

class TrainInfo extends Sprite {
	
	private var trainIcon:Bitmap;
	private var trainLabel:Label;
	private var trainButton:TextButton;
	
	public function TrainInfo() {
		trainIcon = new Bitmap();
		addChild(trainIcon);
		
		trainLabel = new Label(12, 0xFFFFFF);
		trainLabel.y = 60;
		addChild(trainLabel);
		
		trainButton = UIUtil.getTextButton("", ["button_yellow_off", "button_yellow_on", "button_yellow_off"], buttonHandler);
		trainButton.x = 10;
		trainButton.y = 80;
		addChild(trainButton);
	}
	
	private function buttonHandler(button:TextButton):void {
		
	}
	
	public function update(iconUrl:String, labelText:String, buttonText:String):void {
		trainIcon.bitmapData = Global.assetsManager.getAssetsAsBitmapData(iconUrl, "ui");
		trainLabel.text = labelText;
		trainButton.getLabel().text = buttonText;
	}
	
	public function clear():void {
		
	}
}